package icu.feigroup.domain.trade.service.locak.factory;

import icu.feigroup.domain.trade.model.entity.GroupBuyActivityEntity;
import icu.feigroup.domain.trade.model.entity.TradeLockRuleCommandEntity;
import icu.feigroup.domain.trade.model.entity.TradeLockRuleFilterBackEntity;
import icu.feigroup.domain.trade.service.locak.filter.ActivityUsabilityRuleFilter;
import icu.feigroup.domain.trade.service.locak.filter.UserTakeLimitRuleFilter;
import icu.feigroup.types.design.framwork.link.model2.LinkArmory;
import icu.feigroup.types.design.framwork.link.model2.chain.BusinessLinkedList;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

/**
 * projectName:icu.feigroup.domain.trade.service.locak.factory
 *
 * @author 飞
 * @since 2025/2/25 16:01
 * description:交易规则过滤工厂
 */
@Slf4j
@Service
public class TradeLockRuleFilterFactory {


    @Bean("tradeRuleFilter")
    public BusinessLinkedList<TradeLockRuleCommandEntity, DynamicContext, TradeLockRuleFilterBackEntity> tradeRuleFilter(ActivityUsabilityRuleFilter activityUsabilityRuleFilter, UserTakeLimitRuleFilter userTakeLimitRuleFilter) {
        // 组装链
        LinkArmory<TradeLockRuleCommandEntity, TradeLockRuleFilterFactory.DynamicContext, TradeLockRuleFilterBackEntity> linkArmory =
                new LinkArmory<>("交易规则过滤链", activityUsabilityRuleFilter, userTakeLimitRuleFilter);
        // 链对象
        return linkArmory.getLogicLink();
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DynamicContext{
        private GroupBuyActivityEntity groupBuyActivityEntity;
    }
}
